using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_Store_AddStore : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
        {
            BinData();
        }
    }

    private void BinData()
    {
        PccMsg msg = new PccMsg();
          string StID = "0";
          if (Request.QueryString["StID"] != "" && Request.QueryString["StID"] != null)
          {
              StID = Request.QueryString["StID"];

              msg.CreateFirstNode("StName", txtTenChuDe.Text.Trim());
              msg.CreateFirstNode("StID", StID);
              clsWebShop cls = new clsWebShop();
              DataTable dt = null;
              dt = cls.Get_StoreByCondition(msg.GetXmlStr).Tables[0];
              if (dt.Rows.Count > 0)
              {
                  txtTenChuDe.Text = dt.Rows[0]["StName"].ToString();
                  txtDesc.Text = dt.Rows[0]["St_Desc"].ToString();
              }
          }
        
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ReturnPage();
    }

    private void ReturnPage()
    {
        Response.Redirect("Store.aspx?CodeID=" + Request.QueryString["CodeID"]);
    }
    protected void btnAdd_Catalogue_Click(object sender, EventArgs e)
    {
        PccMsg msg = new PccMsg();

        string StID = "0";
        if (Request.QueryString["StID"] != "" && Request.QueryString["StID"] != null)
            StID = Request.QueryString["StID"];

        msg.CreateFirstNode("StID", StID);
        msg.CreateFirstNode("StName", txtTenChuDe.Text.ToString());
        msg.CreateFirstNode("St_Desc", txtDesc.Text.ToString());
        msg.CreateFirstNode("Status", "N");
        msg.CreateFirstNode("UpdID", Session["AdminUserID"].ToString());

        clsWebShop cls = new clsWebShop();
        cls.Ins_Upd_Store(msg.GetXmlStr.ToString());
        
        ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('Success!!!')</script>");
        ReturnPage();

    }
}
